layui.define(["form","jquery"],function(exports){
    var baseConfig = {
            RECHARGE_LIST : "recharge_list",//查看自己的充值记录
            RECHARGE_LIST_ALL : "recharge_list_all",//查看所有的充值记录
            RECHARGE_EXCEL : "recharge_excel",//上传充值记录
            RECHARGE_EDIT_STATUS : "recharge_edit_status",//设置充值到帐状态

            CONSUMER_LIST : "consumer_list",//查看自己的消费记录
            CONSUMER_LIST_ALL : "consumer_list_all",//查看所有的消费记录
            CONSUMER_EXCEL : "consumer_excel",//上传消费记录
            INVOICE_REVIEW : "invoice_review",//审核发票

            GOODS_LIST : "goods_list",//查看自己的商品列表
            GOODS_EDIT_STATUS : "goods_edit_status",//设置商品出关单状态
            SEND_GOODS_LIST : "send_goods_list",//商品发货管理
            GOODS_LIST_ALL : "goods_list_all",//查看所有的商品列表

            ADMINUSER_LIST : "userAdmin_list",//员工列表
            ADMINUSER_REVIEW : "userAdmin_review",//员工审核

            DATADEFINE_LIST : "datadefine_list",//数据项配置 全息
            SYSTEM_RECORD : "systemRecord_list",//系统备份
            ROLE_LIST : "roleAdmin_list",//角色列表
            SUMMARY_LIST : "summary_list",//员工数据汇总
            INDEX_DATA : "index_data",//首页数据
            ALL: "_ALL_",
            checkPrivalege: function( name){
                var userInfo = JSON.parse( window.sessionStorage.getItem( "userInfo"));
                var roleContent = userInfo.role.content;
                var roles = roleContent.split( ",");
                for( var i = 0 ; i< roles.length ; i++){
                    var role = roles[i];
                    if( role == baseConfig.ALL || role == name){
                        return true;
                    }
                }
                return false;
            },
            formatDate: function( dateStr){
                var date = new Date( dateStr);
                var currMonth = date.getMonth() + 1;
                var str = "";
                if( date.getDate() < 10){
                    str = "0" + date.getDate();
                }else{
                    str = date.getDate();
                }

                switch ( currMonth) {
                    case 1: str += " Jan ";break;
                    case 2: str += " Feb ";break;
                    case 3: str += " Mar ";break;
                    case 4: str += " Apr ";break;
                    case 5: str += " May ";break;
                    case 6: str += " June ";break;
                    case 7: str += " July ";break;
                    case 8: str += " Aug ";break;
                    case 9: str += " Sept ";break;
                    case 10: str += " Oct ";break;
                    case 11: str += " Nov ";break;
                    case 12: str += " Dec ";break;
                }
                str += date.getFullYear();
                return str;
            },
            formatDateToDay: function( dateStr){
                var date = new Date( dateStr);
                var y = date.getFullYear().toString();        // 年
                var m = (date.getMonth() + 1).toString();     // 月
                var d = date.getDate().toString();            // 日
                if( m < 10){
                    m = "0" + m;
                }
                if( d < 10){
                    d = "0" + d;
                }
                return y + "-" + m + "-" + d;
            },
            getDay: function( dateStr){
                var date = new Date( dateStr);
                var str = date.getDate();
                if( str < 10){
                    str = "0" + str;
                }
                return str;
            },
            showImg: function( src, rate){//弹窗  rate是宽和高的比例
                var maxHeight = $(window).height();
                if( !src){
                    return;
                }
                var height = maxHeight + "px";
                var width = (maxHeight * rate) + "px";
                layer.open({
                    type: 1,
                    skin: 'layui-layer-rim', //加上边框
                    area: [ width, height], //宽高
                    shadeClose: true, //开启遮罩关闭
                    end: function (index, layero) {
                        return false;
                    },
                    content: "<div style=\"text-align:center\"><img style=\"width:" + width + ";height:"+ height + "\" src=\"" + src + "\" /></div>"
                });
            }
        };

    exports( "baseConfig", baseConfig);
})
